<?PHP

	class tpl_roomlist {
		
		public static function roomlist($rooms,$acp){
			
			$acp_button = $acp ? tpl_form::button($GLOBALS['LANG']->lang_roommgmt->roomlist,"window.open('./index.php?act=admin{$GLOBALS['OUTPUT']->ses}')") : '';
			
			$reload_button = tpl_form::button($GLOBALS['LANG']->lang_roommgmt->reload,"document.location='./index.php?act=roomlist{$GLOBALS['OUTPUT']->ses}'");
			$create_room_button = tpl_form::button($GLOBALS['LANG']->lang_roommgmt->create_room,"document.location='./index.php?act=create_room{$GLOBALS['OUTPUT']->ses}'");
			
			// Compile the list of rooms
			$room_html = '';
			
			if(empty($rooms))
				$room_html = "<div class='row start'>{$GLOBALS['LANG']->lang_roommgmt->no_rooms}</div>";
			else{
				$offrow = false;
				
				foreach($rooms as $row=>$val){
					
					if($val['pass_required']){
						$action = "tmp = new window.parent.browser_tab('{$val['rdata']['rid']}pwreq',{'url':'./index.php?act=pwreq&rid={$val['rdata']['rid']}{$GLOBALS['OUTPUT']->ses}'},new window.parent.tabBarTabDisplay('{$val['rdata']['name']}')); tmp.activate();";
					}else{
						$action = "window.parent.addTab({$val['rdata']['rid']},1,'{$val['rdata']['name']}');";
					}
					
					$room_html .= "<div class='row ".($offrow ? 'odd' : 'even')."'><a href='#' onclick=\"{$action}\"><b>{$val['rdata']['name']}</b></a> ({$val['ppl']} / {$val['rdata']['max_users']} {$GLOBALS['LANG']->lang_roommgmt->users})<br /><i>{$val['rdata']['topic']}</i></div>";
					$offrow = !$offrow;
				}
			}
			
			return	tpl_globals::header() .
				tpl_globals::global_styles_shared() .
				tpl_globals::inner_global_styles() .
				tpl_globals::form_styles2() .
				<<<EOV
<div class='form_container'>
	<div class='row title'>{$GLOBALS['LANG']->lang_roommgmt->roomlist}</div>
	<div class='row start'>{$GLOBALS['LANG']->lang_roommgmt->roomlist_instructions}</div>
	{$room_html}
</div>

<br />

<div class='form_container'>
	<div class='row end'>
		{$create_room_button}
		{$reload_button}
	</div>
</div>
EOV
.
				tpl_globals::footer(false);
				
		}
		
	}

?>